package com.fingerchar.core.util;

import lombok.extern.slf4j.Slf4j;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.methods.response.EthTransaction;
import org.web3j.protocol.core.methods.response.Transaction;
import org.web3j.protocol.http.HttpService;

import java.io.IOException;

/**
 * 代币 工具类
 * @author tangzf
 * @date 2022/9/15
 */
@Slf4j
public class ERC20Util {

    private static Web3j web3j = Web3j.build(new HttpService("https://bsc-testnet.nodereal.io/v1/ea05893e6278442bb227581875de5d44"));

    public Transaction getTransByHash(String hash) throws IOException {

        EthTransaction result = web3j.ethGetTransactionByHash(hash).send();
        if(null == result.getError()){
            return result.getTransaction().orElse(new Transaction());
        }
        return null;
    }

}
